<?php

class Application_Form_SoaAdd extends Zend_Form
{

	public function init()
	{
		$salesrepDb = new Application_Model_SalesrepMapper();

		$this->setMethod('post');
		$this->setAction('add');
		
		$createdOn = new Zend_Form_Element_Hidden('createdOn');
		$createdOn->setValue(date('Y-m-d'));
		
		$createdBy = new Zend_Form_Element_Hidden('createdBy');
		$createdBy->setValue(Zend_Auth::getInstance()->getIdentity()->username);
		
		$status = new Zend_Form_Element_Hidden('status');
		$status->setValue('entered');

		$salesrepname = new Zend_Form_Element_Select('salesRepName');
		$salesrepname->setLabel('SalesRep name');
		$salesrepname->addMultiOption('', '');
		$salesrepname->addMultiOptions($salesrepDb->getAll('form'));
		$salesrepname->setRequired(true);

		$customerNumber = new Zend_Form_Element_Select('customerNumber');
		$customerNumber->addMultiOption('', 'Select SalesRep');
		$customerNumber->setRegisterInArrayValidator(false);
		$customerNumber->setLabel('Customer');
		$customerNumber->setRequired(true);
		
		$budgetCategory = new Zend_Form_Element_Radio('budgetCategory');
		$budgetCategory->setLabel('Budget');
		$budgetCategory->addMultiOptions(array('lcm' => 'LCM budget', 'sonder' => 'sonder budget', 'sfb' => 'self funding budget'));
		$budgetCategory->setValue('lcm');
		$budgetCategory->setRequired(true);
		
		$campaignDesc = new Zend_Form_Element_Select('campaignDesc');
		$campaignDesc->setLabel('Campaign');
		$campaignDesc->addMultiOptions(array('Skylanders Single Toys 3 for 2' => 'Skylanders Single Toys 3 for 2', 'MBU 20% Aktion' => 'MBU 20% Aktion', 'regular SOA' => 'regular SOA'));
		$campaignDesc->setRequired(true);
		
		$startDate = new ZendX_JQuery_Form_Element_DatePicker('startDate', array('jQueryParams' => array('dateFormat' => 'yy-mm-dd')));
		$startDate->setLabel('Starting date');
		$startDate->setRequired(true);
		
		$endDate = new ZendX_JQuery_Form_Element_DatePicker('endDate', array('jQueryParams' => array('dateFormat' => 'yy-mm-dd')));
		$endDate->setLabel('Ending date');
		$endDate->setRequired(true);
		$endDate->addPrefixPath('Custom_Validate', 'Custom/Validate/', 'validate');
		$endDate->addValidator('Quarteroverlap', true);

		$submit = new Zend_Form_Element_Submit('submit');
		$submit->setLabel('Create and continue adding items ');

		$this->addElements(array($createdOn, $createdBy, $status ,$salesrepname, $customerNumber, $budgetCategory, $campaignDesc, $startDate, $endDate, $submit));
	}


}

